package com.yoomiito.app.ui.list

import cn.droidlover.xdroidmvp.net.ApiException
import cn.droidlover.xdroidmvp.net.ApiSubscriber
import cn.droidlover.xdroidmvp.net.XApi
import com.yoomiito.app.base.AppConfig
import com.yoomiito.app.base.BaseActPresenter
import com.yoomiito.app.model.BaseList
import com.yoomiito.app.model.sdd.SddFreeGoodsOrderInfo
import com.yoomiito.app.net.YmApi
import com.yoomiito.app.utils.Const
import com.yoomiito.app.utils.L

class ReceiveListOfGiftPresenter(appConfig: AppConfig) :BaseActPresenter<ReceiveListOfGiftActivity>(appConfig){
    /**
     * 送多多--赠品订单列表
     */
    fun sddFreeGoodsOrderLIst(page:Int,type:Int){
        YmApi.getYmService()
                .sddFreeGoodsOrderList(type,page, Const.PageSize.Size_40)
                .compose(v.bindToLifecycle())
                .compose(XApi.getApiTransformerData())
                .compose(XApi.getScheduler())
                .subscribe(object : ApiSubscriber<BaseList<SddFreeGoodsOrderInfo>>(){
                    override fun onSuccess(t: BaseList<SddFreeGoodsOrderInfo>?) {
                        v.data(t)
                    }

                    override fun onFail(error: ApiException?) {
                        v.dismissLoading()
                    }

                })
    }
}